home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group99a.txt / 000187_icon-group-sender _Tue Sep 7 16:59:11 1999.msg < prev    next >
Internet Message Format  |  2000-09-20  |  6KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) id QAA07190
  4.     for icon-group-addresses; Tue, 7 Sep 1999 16:58:51 -0700 (MST)
  5. Message-Id: <199909072358.QAA07190@baskerville.CS.Arizona.EDU>
  6. From: "Frank Lhota" <lhotaf@lexma.meitech.com>
  7. To: <icon-group@optima.CS.Arizona.EDU>, "Garry" <memphis@macconnect.com>
  8. Subject: Re: Is open(..,"b") broken in MPW Icon 9.0?
  9. Date: Fri, 3 Sep 1999 09:04:21 -0400
  10. X-Priority: 3
  11. X-MSMail-Priority: Normal
  12. X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
  13. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  14. Status: RO
  15.  
  16. Amazingly enough, it looks like the code for the Icon open function does not
  17. include the right code for opening a file in bi-directional mode. I think I
  18. can help you patch the source code, however, so that it will work correctly
  19.  
  20. In the file RUNTIME\FSYS.R, search for the text "fsys.05". This search
  21. should bring you to the following comment:
  22.  
  23. /*
  24.  * The following code is operating-system dependent [@fsys.05].  Handle open
  25.  *  modes.
  26.  */
  27.  
  28. Previous to this section, the bits of the variable status have been set to
  29. indicate the desired open mode. The bits in status are translated into a
  30. mode string to be passed on to the C fopen function. Right before this
  31. comment, the first mode character is set to one of 'r', 'w', or 'a'. The
  32. possible mode parameter characters are, unfortunately, not that well
  33. standardized. The code after this comment should have the OS dependent code
  34. for handling the addition open modes. For the Macintosh, we see
  35.  
  36. #if MACINTOSH
  37.       /* nothing to do */
  38. #endif     /* MACINTOSH */
  39.  
  40. This is undoubtedly wrong; there are definitely things to do here for the
  41. Mac. At a minimum, we should add '+' to mode if both the Fs_Read and
  42. Fs_Write flags in status are on. Also, I believe that we also need to
  43. process the Fs_Untrans flag for the Macintosh, since the Mac does not use
  44. the Unix text file format. I am not sure what mode characters MPW uses to
  45. indicate translated / untranslated mode; in my fix, I assume that MPW fopen
  46. uses 't' for translated mode, 'b' for untranslated mode. Given, this, the
  47. MACHINTOSH section for the open modes should look like this:
  48.  
  49. #if MACINTOSH
  50.       if ((status & (Fs_Read|Fs_Write)) == (Fs_Read|Fs_Write)) {
  51.          mode[1] = '+';
  52.          mode[2] = ((status & Fs_Untrans) != 0) ? 'b' : 't';
  53.          }
  54.       else mode[1] = ((status & Fs_Untrans) != 0) ? 'b' : 't';
  55. #endif     /* MACINTOSH */
  56.  
  57. Try making this change and rebuild.
  58.  
  59. ----- Original Message -----
  60. From: Garry <memphis@macconnect.com>
  61. To: Frank Lhota <lhotaf@lexma.meitech.com>;
  62. <icon-group@optima.CS.Arizona.EDU>
  63. Sent: Thursday, September 02, 1999 6:17 PM
  64. Subject: Re: Is open(..,"b") broken in MPW Icon 9.0?
  65.  
  66.  
  67. At 12:32 -0400 1999-09-02, Frank Lhota wrote:
  68. >The Icon file management routines are based on the C <stdio.h> facilitates.
  69. >The Icon open mode specifications are mapped to the C fopen mode parameter,
  70. >and unfortunately the available fopen modes vary from platform to platform.
  71. >
  72. >Do you have a C compiler for the Macintosh MPW environment? If so, try to
  73. >see which C fopen modes will give you the desired results. From this, we
  74. can
  75. >figure out the how to fix the Icon run time code.
  76.  
  77. Thanks for your response Frank. I don't quite understand; the mode to pass
  78. to fopen for updating a file is "r+" on every platform (the lower level Mac
  79. toolbox call is something funky but the standard C library function is
  80. "standard").  I checked the "r+" mode on my problem file using a C program.
  81. "f = fopen( "Testfile", "r+" );" works fine.   Thereafter I can read lines
  82. with fgets() or write to random locations using fseek() and fprintf() or
  83. fputs().
  84.  
  85. Of course I'm using an up-to-date StdCLib (I'm using MacOS 8.6 and MPW / MrC
  86. with Universal Interfaces 3.2).  I'm also using the new file system, HFS+,
  87. which (I hope) is transparent at the level of standard C functions.  Maybe
  88. MPW Icon (9.0)  just needs to be recompiled against new libraries -- but
  89. that's easier said than done.  It would become somewhat larger (because of
  90. changing from 68K to PowerPC RISC instructions) and much faster.  Would
  91. anyone be willing to help me?
  92.  
  93. (As for my immediate problem -- it is perhaps most simply solved by using
  94. Icon for the analysis and reporting functions, in which it excels, and
  95. dropping back to C for writing my files in the first place. Since what I'm
  96. working on is a notekeeper/outliner to use in my MPW programming
  97. environment, I can tie Icon and C programs together using the Shell.)
  98.  
  99.  
  100. >----- Original Message -----
  101. >From: Garry <memphis@macconnect.com>
  102. >
  103. >> The most up-to-date Icon available for the Macintosh MPW environment is
  104. >> version 9.0, which I think may have been implemented by Bob Alexander
  105. >> (email address?). I've implemented most of an outline processor / note
  106. >> organizer for MPW using Icon; maybe I'll proceed to try using it for
  107. >> keeping source code in outline form, BUT after more than a month of fun
  108. >> with Icon I've run into a problem!!  I can't open a file for update
  109. >> (read/write).  When I follow the Icon practice of opening my file with
  110. >> "b" mode I find that I can read it but I can not write to the file.  For
  111. >> example if I execute
  112. >>    f := open( "Testfile", "b" )
  113. >>    seek( f )
  114. >>    writes( f, "**" )
  115. >> where "Testfile" is a small test file created previously, then I get the
  116. >> message
  117. >>    Run-time error 214
  118. >>    input/output error
  119. >>
  120. >> I've tried specifying "r+" mode or "b+r" or "ub" mode without success.
  121.  
  122. --
  123.    Garry Roseman  <mailto:memphis@macconnect.com>
  124.    Tech Writer & Freelance Programmer
  125.    Memphis, TN USA
  126.  
  127.  
  128.  
  129.